package com.ruoyi.common.utils.file.upload;


import com.ruoyi.common.exception.file.InvalidExtensionException;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.project.system.domain.SysFile;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

public abstract class FileUploadTemplate {
    public abstract void setFilePath(SysFile fileInfo);
    public abstract void setFTPPath(SysFile fileInfo);
    public abstract void setFileName(MultipartFile file, SysFile fileInfo);
    public abstract void setAllowedExtension(SysFile fileInfo);
    public abstract void setIsFTP(SysFile fileInfo);
    public SysFile template(MultipartFile file, SysFile fileInfo) throws IOException, InvalidExtensionException {
        setFilePath(fileInfo);
        setFTPPath(fileInfo);
        setAllowedExtension(fileInfo);
        setFileName(file,fileInfo);
        setIsFTP(fileInfo);
        FileUploadUtils.upload(fileInfo, file);
        return fileInfo;
    }
}
